package com.xiangyang.pos;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

import com.xiangyang.pos.activity.EmployeeLoginActivity;

public class MainActivity extends AppCompatActivity {

    private ImageView ivRed;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_main);

        initView();

        handler.sendEmptyMessageDelayed(1001,5000);

    }


    private void initView(){
        ivRed= (ImageView) findViewById(R.id.iv_red);


        TranslateAnimation translateAnimation =
                new TranslateAnimation(Animation.ABSOLUTE, 0f,
                        Animation.RELATIVE_TO_SELF, 0f,
                        Animation.ABSOLUTE, 0.1f,
                        Animation.RELATIVE_TO_PARENT, -0.3f);
        translateAnimation.setDuration(5000);
        translateAnimation.setFillAfter(true);
        ivRed.startAnimation(translateAnimation);
    }


    Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what==1001){
                Intent intent=new Intent(MainActivity.this, EmployeeLoginActivity.class);
                startActivity(intent);
                finish();
            }
        }
    };


}
